import { defaultRequest as rq } from "./request";
import type { R } from "./request";

const baseURL = 'http://localhost:9998'

export const fileApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL, responseType: 'blob' }
  return rq.get<any>("/file", p);
};

/* =======================================================
演员
======================================================= */

export const reloadApi = (params?: object): Promise<R<any>> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<R<any>>("/actor/reload", p);
};

export const actorsApi = (params?: object): Promise<R<any>> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<R<any>>("/actors", p);
};

export const actorApi = (params?: object): Promise<R<any>> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<R<any>>("/actor", p);
};

export const actorAvatarApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL, responseType: 'blob' }
  return rq.get<any>("/actor/avatar", p);
};

export const actorSaveApi = (data?: object): Promise<R<any>> => {
  let p: object = { baseURL: baseURL }
  return rq.post<R<any>>("/actor", data, p);
};

/* =======================================================
视频
======================================================= */

export const actorVideosApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/videos", p);
};

export const actorVideosRefreshApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/videos/refresh", p);
};

export const actorVideosRefreshAllApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/videos/refresh/all", p);
};

export const actorVideoSearchApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/videos/search", p);
};

export const tagsApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/tags", p);
};

/* =======================================================
缩略图
======================================================= */

export const actorThumbsApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/thumbs", p);
};

export const actorThumbCreateApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/thumb/create", p);
};

// 清空无效缩略图
export const actorThumbClearApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/thumb/clear", p);
};


/* =======================================================
文件操作
======================================================= */
export const openFolderApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/open/folder", p);
};

export const openConfigApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/open/config", p);
};

export const openPicApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/open/pic", p);
};

export const openVideoApi = (params?: object): Promise<any> => {
  let p: object = { params: params, baseURL: baseURL }
  return rq.get<any>("/open/video", p);
};